package com.example.marksixanim

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import android.widget.Toast
import java.util.*

class MainActivity : AppCompatActivity() {

    private val markSixView: MarkSixView by lazy {
        findViewById<MarkSixView>(R.id.mark_six)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    fun startScreen(view: View) {
        markSixView.startScreenExit()
    }

    fun openResult(view: View) {
        if (markSixView.isScreenOn) {
            val ballList: MutableList<BallInfo> = ArrayList()
            ballList.add(BallInfo("02", "红", "猴"))
            ballList.add(BallInfo("21", "蓝", "鸡"))
            ballList.add(BallInfo("32", "绿", "狗"))
            ballList.add(BallInfo("10", "红", "猪"))
            ballList.add(BallInfo("11", "蓝", "牛"))
            ballList.add(BallInfo("25", "绿", "龙"))
            ballList.add(BallInfo("48", "绿", "兔"))
            markSixView.openResult(ballList)
            markSixView.callBack = object : MarkSixView.CallBack {
                override fun onFinish() {
                    Toast.makeText(this@MainActivity, "动画执行完毕", Toast.LENGTH_SHORT).show()
                }
            }
        } else {
            Toast.makeText(this@MainActivity, "请拉开帷幕先", Toast.LENGTH_SHORT).show()
        }
    }

    fun reset(view: View) {
        markSixView.reset()
    }
}
